package com.shujia;

import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

public class jedisClusterDemo {
    public static void main(String[] args) {
        Set<HostAndPort> nodes = new HashSet<>();
        HostAndPort hostAndPort2 = new HostAndPort("192.168.20.90", 6380);
        HostAndPort hostAndPort1 = new HostAndPort("192.168.20.90", 6381);
        HostAndPort hostAndPort = new HostAndPort("192.168.20.90", 6382);
        nodes.add(hostAndPort2);
        nodes.add(hostAndPort1);
        nodes.add(hostAndPort);
        JedisCluster jedisCluster = new JedisCluster(nodes);
        jedisCluster.set("cluster","test Jedis");
        String cluster = jedisCluster.get("cluster");
        System.out.println(cluster);
    }
}
